Code Monkey home page Code Monkey logo

m2t3-magento's People

Contributors

bennsel avatar renttek avatar tomtone avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

bka

m2t3-magento's Issues

INDEXER: Generated URLs are wrong if "use rewrites" is disabled

If the option "Use Web Server Rewrites" (path: "web/seo/use_rewrites") isn't set or set to 0 and urls are being generated via CLI, the base url contains the word "magento" instead if "index.php".

For example:
Store base url: http://magento.local/
Use rewrites: not set
Category name: foobar

Expected: http://magento.local/index.php/foobar.html
Actual: http://magento.local/magento/foobar.html

The cause of this behaviour is the following code:

// vendor/magento/module-store/Model/Store.php:677
   /**
     * Append script file name to url in case when server rewrites are disabled
     *
     * @param   string $url
     * @return  string
     */
    protected function _updatePathUseRewrites($url)
    {
        if ($this->getForceDisableRewrites() || !$this->getConfig(self::XML_PATH_USE_REWRITES)) {
            if ($this->_isCustomEntryPoint()) {
                $indexFileName = 'index.php';
            } else {
                $indexFileName = basename($_SERVER['SCRIPT_FILENAME']);
            }
            $url .= $indexFileName . '/';
        }

        return $url;
    }

First of all, the call to "$this->getConfig(self::XML_PATH_USE_REWRITES)" returns the value 0 as string, which is then converted (via !) to a bool.
Problem here is, that even if the value is 0, it is returned as an non empty string, which in php will be converted to a true.

The next problem is, that the url generation was never built for cli/indexer use.
In case of any call of "bin/magento ..." the $_SERVER['SCRIPT_FILENAME'] will be "bin/magento".
The function basename then returns the value "magento" which is then appended to the base url.


The workaround would be to set "Use Web Server Rewrites" to true/yes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.